import java.awt.*;
/**
 * The class MovableEnt creates a MovableEntity object that extends GridEntity 
 * 
 * @author      Zachary Bellido
 * @version     0.01
 */
public class MovableEnt extends GridEntity
{
    private int myCoordX;
    private int myCoordY;
    private char mySymbol;
    private int health;
    protected int stepInterval = 0;
    private boolean diagonalBool = false;
    /**
     * Constructor for MoveableEnt
     */
    public MovableEnt(char symbol, int coordX, int coordY)
    {
        super(symbol, coordX, coordY);
    }
    
    /**
     * Preform actions every timer tick
     * 
     * @pre     object must be initialized     
     * @param   none
     * @return  none
     * @post    none    
     */
    public void step(){

    }
    
    /**
     * The move() method will change the location of a MoveableEnt
     *
     * @pre     the entity must be constructed     
     * @param   x (the x coord) y (the y coord)
     * @return  void
     * @post   the MoveableEnt must be at x,y
     */
    public void move(int x, int y){
        if (Grid.isEmpty(getCoordX() + x, getCoordY() + y)) {
            
            setCoordX(getCoordX() + x);
            setCoordY(getCoordY() + y);
        }
    }
    
    /**
     * The moveRestricted() restricts entity movement
     *
     * @pre     the entity must be constructed     
     * @param   x (the x coord) y (the y coord)
     * @return  void
     * @post    the MoveableEnt must be at x,y
     */
    public void moveRestricted(int x, int y){
        //Limit movement to 1 in each direction
        if (x != 0)
            x = x / Math.abs(x);
        if (y != 0)
            y = y / Math.abs(y);
        //Check for diagonals
        if (Math.abs(x) + Math.abs(y) > 1){   
            diagonalBool = !diagonalBool;
            //Alternate between vertical/horizontal movement
            if (diagonalBool)
                x = 0;
            else
                y = 0;
        }
        move(x,y);
    }
    
    /**
     * The getHealth() method is a getter for the health
     *
     * @pre     health
     * @param   none
     * @return  health
     * @post    health is returned
     */
       public int getHealth(){
        return health;
    }
}
